
package com.example;

/**
 * KbShrtcutReminder
 * DataManager.java
 * Purpose: Handles the visibility of two interfaces according to user commandsfor hiding or displaying
 *
 * @author Despicabal Me
 * @version 1.1 23/12/2010
 */
public class ServiceManager implements Runnable{
    ReminderInterface rInterface;
    SearchInterface sInterface;
    DataManager dManager;

    /**
     * initilaize variables, two interfaces and the datamanager object
     */
    public ServiceManager(){
        dManager = new DataManager();
        rInterface = new ReminderInterface();
        sInterface = new SearchInterface(dManager);
    }

    /**
     * makes the search interface visible
     */
    void showSearchWindow() {
        if (!sInterface.isVisible()){
            if (rInterface.isVisible()){
                rInterface.setVisible(false);
            }
            sInterface.setVisible(true);
            sInterface.setLocation(1090, 20);
        }
    }

    /**
     * submit the handling of reminder function to a new thread
     */
    public void run() {
        if (!rInterface.isVisible()){
            if (sInterface.isVisible()){
                sInterface.setVisible(false);
                
            }
            rInterface.setVisible(true);
            rInterface.setLocation(1090, 20);
            dManager.displayShortcuts(rInterface);
        } 
    }

    /**
     * makes the reminder interface visible
     */
    void showrReminderWindow() {
        if (sInterface.isVisible()){
                sInterface.setVisible(false);
        }
        rInterface.setVisible(true);
        rInterface.setLocation(1090, 20);
        
    }

}
